﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using CE.Global;
using CE.Provider;
public partial class Provider_CarInsurance_ViewProviderCarCapacityExcessClaim : System.Web.UI.Page
{
    string PageName = "CXCI";
    string SubPageName = "CXCIEXSS";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (!Page.IsPostBack)
        {
            CarClaimExpInfoList _ccexplist = new CarClaimExpInfoList();
            CarClaimExpInfoDB _ccexpdb = new CarClaimExpInfoDB();
            _ccexplist = _ccexpdb.GetProviderCarClaimExpInfoList(Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));
            if (_ccexplist != null)
            {
                for (int i = 0; i < _ccexplist.Count; i++)
                {
                    ddlClaimValue.Items.Add(new ListItem(_ccexplist[i].Description, _ccexplist[i].ProviderCarClaimExpId.ToString()));
                }
            }

            if (Page.Request["CarClaimExcessId"] != null)
            {
                ddlClaimValue.Text = Page.Request["CarClaimExcessId"].ToString();
                lnkNewClaimInfo.NavigateUrl = "~/Provider/CarInsurance/ProviderCarCapacityExcessClaim.aspx?CarClaimExcessId=" + ddlClaimValue.Text;
            }
        }
    }

    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/CarInsurance/TableMatching.aspx");
    }

    protected void ddlClaimValue_SelectedIndexChanged(object sender, EventArgs e)
    {
        lnkNewClaimInfo.NavigateUrl = "~/Provider/CarInsurance/ProviderCarCapacityExcessClaim.aspx?CarClaimExcessId=" + ddlClaimValue.Text;
        //ClientScript.RegisterStartupScript(this.GetType(), "TestAlert", "alert('test');", true);
    }

    private void CheckMainPageAccess()
    {
        Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), PageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
    }

    private void CheckSubPageAccess()
    {
        Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), SubPageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
        else if (PageAccess == 100)
        {
            lnkNewClaimInfo.Visible = false;
        }
    }

}
